/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package pw.yitree.game;

import javax.persistence.AttributeConverter;

/**
 *
 * @author Administrator
 */
public class FiveElementConverter implements AttributeConverter<FiveElement, String> {

    @Override
    public String convertToDatabaseColumn(FiveElement value) {
        if (value == null) {
            return null;
        }

        return value.getCode();
    }

    @Override
    public FiveElement convertToEntityAttribute(String value) {
        if (value == null) {
            return null;
        }

        return FiveElement.fromCode(value);
    }
}
